package com.dicsystems.myrec;

import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost.TabSpec;

public class HomeActivity extends TabActivity {

	private Context me = this;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		addTab("0", R.string.calendar, android.R.drawable.ic_menu_my_calendar, new Intent(me, CalendarActivity.class));
		addTab("1", R.string.list, android.R.drawable.ic_menu_agenda, new Intent(me, TodoListActivity.class));
		addTab("2", R.string.setting, android.R.drawable.ic_menu_manage, new Intent(me, CalendarActivity.class));

		setColor(0, R.color.blue);
		setColor(1, R.color.olive);
		setColor(2, R.color.beige);

		getTabHost().setCurrentTab(getIntent().getIntExtra("index", 0));
	}

	private void addTab(String tag, int label, int icon, Intent intent) {
		TabSpec spec = getTabHost().newTabSpec(tag);
		spec.setIndicator(getResources().getString(label), getResources().getDrawable(icon));
		spec.setContent(intent);
		getTabHost().addTab(spec);
	}

	private void setColor(int index, int color) {
		getTabHost().getTabWidget().getChildAt(index).setBackgroundColor(getResources().getColor(color));
	}
}
